<?php
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/jquery-ui-1.8.11.custom.min.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/jquery.tipsy.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/jquery.wysiwyg.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/art-dialog/jquery.artDialog.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/art-dialog/plugins/iframeTools.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/jquery.validationEngine.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->adminPath."/js/jquery.validationEngine-zh_CN.js",CClientScript::POS_HEAD);


?>
<link rel="stylesheet" type="text/css" href="<?php echo $this->adminPath; ?>/css/jquery-ui.css" />
<link rel="stylesheet" type="text/css" href="<?php echo $this->adminPath; ?>/js/art-dialog/skins/blue.css" />
<link rel="stylesheet" type="text/css" href="<?php echo $this->adminPath; ?>/js/validationEngine.jquery.css" />
<style type="text/css">
    .st-labeltext {
        color: #3C5868;
        display: block;
        float: left;
        font-size: 12px;
        line-height: 20px;
        padding-right: 10px;
        padding-top: 3px;
        width: 60px;
    }
</style>
<div style="z-index: 770;" class="albox succesbox">
    <span id="is_type" style="color: red;">基本信息</span>
</div>
<form id="form"  method="post" >
<div class="st-form-line" style="z-index: 580;">
    <span class="st-labeltext">资源名称:</span>
    <input type="text" value="<?php echo $info->opus_title; ?>"  name="Opus[opus_title]" style="width:300px;margin-bottom: 10px;float: left" id="opus_title" class="st-success-input validate[required,maxSize[50]]"  data-errormessage-range-overflow="资源名称不得大于40个字" data-errormessage-value-missing="资源名称不得为空" >
    <div class="clear" style="z-index: 570;"></div>
</div>
<div style="z-index: 680;" class="st-form-line">
    <span class="st-labeltext">资源描述:</span>
    <textarea data-errormessage-value-missing="资源描述不得为空" id="description" name="Opus[opus_desc]" class="Opus[required,minSize[6],maxSize[250]]" style="width:500px;background-color: #eaf2ec;" cols="47" rows="3"><?php echo $info->opus_desc; ?></textarea>
    <div style="z-index: 670;" class="clear"></div>
</div>
<div style="z-index: 680;" class="st-form-line">
    <span class="st-labeltext">作品类型:</span>
    <select id="opus_type" name="Opus[opus_type]">
        <option <?php if($info->opus_type ==1){ ?>selected="selected"<?php } ?> value="1">图片</option>
        <option <?php if($info->opus_type ==2){ ?>selected="selected"<?php } ?> value="2">视频</option>
    </select>
    <div style="z-index: 670;" class="clear"></div>
</div>
<div class="st-form-line" style="z-index: 580;">
    <span class="st-labeltext">发布者ID:</span>
    <input type="text" value="<?php echo $info->st_id; ?>"  name="Opus[st_id]" style="width:300px;margin-bottom: 10px;float: left" id="st_id" class="st-success-input"   >
    <div class="clear" style="z-index: 570;"></div>
</div>
<div style="z-index: 680;" class="st-form-line">
    <span class="st-labeltext">作品上传来:</span>
    <select id="opus_type" name="Opus[opus_from]">
        <option <?php if($info->opus_from ==""){ ?>selected="selected"<?php } ?> value="">-</option>
        <option <?php if($info->opus_from =="S"){ ?>selected="selected"<?php } ?> value="S">学生</option>
        <option <?php if($info->opus_from =="T"){ ?>selected="selected"<?php } ?> value="T">老师</option>
    </select>
    <div style="z-index: 670;" class="clear"></div>
</div>
    <div class="st-form-line" style="z-index: 620;">
        <span class="st-labeltext">作品来源类型:</span>
        <li style="display:inline-block;width:120px;">
            <input type="radio" <?php if($info->opus_source_type=="作品上传"){ ?>checked="checked"<?php } ?> name="Opus[opus_source_type]" value="作品上传" >
            <label for="WedoShl_status_0">作品上传</label>
        </li>
        <li style="display:inline-block;width:120px;">
            <input type="radio" <?php if($info->opus_source_type=="课堂资源"){ ?>checked="checked"<?php } ?> name="Opus[opus_source_type]" checked="checked" value="课堂资源" >
            <label for="WedoShl_status_1">课堂资源</label>
        </li>
        <div class="clear" style="z-index: 610;"></div>
    </div>






    <div class="st-form-line" style="z-index: 580;">
        <span class="st-labeltext">总赞数:</span>
        <input type="text" value="<?php echo $info->total_zan; ?>" name="Opus[total_zan]" style="width:50px;margin-bottom: 10px;float: left" id="total_zan" class="st-success-input validate[custom[number]]"  data-errormessage-custom-error="请填写数字" >
        <div class="clear" style="z-index: 570;"></div>
    </div>
    <div class="st-form-line" style="z-index: 650;">
        <span class="st-labeltext">资料路径</span>
        <a original-title="选择资料" href="javascript:uploadifyAction('thumbWarp','opus_path'); " style="float: left"  class="icon-button tips">
            <img width="18" height="18" src="<?php echo $this->adminPath; ?>/img/icons/sidemenu/image.png" alt="icon">
        </a>
        <ul id="thumbWarp">
            <input style="width: 300px" type="text" name="file" value="<?php echo $info1->opus_path; ?>">
        </ul>
        <div class="clear" style="z-index: 640;"></div>
    </div>
<div class="st-form-line button-box" style="z-index: 460;">
    <input type="submit" class="st-button" value="保存" id="submit" name="button">
</div>
</form>

<script type="text/javascript">
    function uploadifyUpdateRemove(fileId,attrName){
        if(confirm('本操作不可恢复，确定继续？')){
            $("#"+attrName+fileId).remove();
        }
    }
    $('#traffic_info').wysiwyg({
        controls: {
            bold : {visible : true},
            italic        : { visible : true },
            strikeThrough : { visible : true },
            underline     : { visible : true },
            separator00 : { visible : true },
            justifyLeft   : { visible : true },
            justifyCenter : { visible : true },
            justifyRight  : { visible : true },
            justifyFull   : { visible : true },
            separator01 : { visible : true },
            indent  : { visible : true },
            outdent : { visible : true },
            separator02 : { visible : true },
            subscript   : { visible : true },
            superscript : { visible : true },
            separator03 : { visible : true },
            undo : { visible : true },
            redo : { visible : true },
            separator04 : { visible : true },
            insertOrderedList    : { visible : true },
            insertUnorderedList  : { visible : true },
            insertHorizontalRule : { visible : true },
            separator05 : { separator : true },
            createLink:{
                visible : false,
                tooltip : '选择文字添加超链接'
            }

        }
    });
    //图集上传
    function uploadifyAllAction(Warp,Name){
        art.dialog.data('Warp',Warp);
        art.dialog.data('Name',Name);
        art.dialog.open(
            '<?php echo Yii::app()->createAbsoluteUrl("admin/uploadify/basicAll",array('num'=>8)); ?>',
            {
                title:'附件上传',
                lock: false,
                width: 600,
                height: 300,
                ok: function () {
                    var fileListWarp = art.dialog.data('fileListWarp');
                    $("#"+Warp).append(fileListWarp);
                    this.close();
                    return false;
                },
                cancelVal: '取消',
                cancel: true
            }

        );
    }


    //缩略图上传
    function uploadifyAction(Warp,Name) {
        art.dialog.data('Warp',Warp);
        art.dialog.data('Name',Name);
        art.dialog.open(
            '<?php echo Yii::app()->createAbsoluteUrl("admin/uploadify/file"); ?>',
            {
                title:'附件上传',
                lock: false,
                width: 600,
                height: 300,
                ok: function () {
                    var fileListWarp = art.dialog.data('fileListWarp');
                    $("#"+Warp).html('<input style="width: 300px" type="text" name="file" value="'+fileListWarp+'">');
                    this.close();
                    return false;
                },
                cancelVal: '取消',
                cancel: true
            }

        );
    }
    function uploadifyRemove(fileId,attrName){
        if(confirm('本操作不可恢复，确定继续？')){
            $.post(
                "<?php echo Yii::app()->createAbsoluteUrl("admin/uploadify/remove"); ?>",
                {imageId:fileId},
                function(res){
                    $("#"+attrName+fileId).remove();
                },
                'json'
            );
        }
    }

    function relatedRemove(fileId,attrName){
        if(confirm('本操作不可恢复，确定继续？')){
            $("#"+attrName+fileId).remove();
        }
    }





    $(function(){
        $("#map").click(function(){
            var city_name = '<?php echo Yii::app()->admin->getState('city_title'); ?>';
            art.dialog.open(
                '<?php echo Yii::app()->createAbsoluteUrl("admin/public/getMap"); ?>',
                {
                    title:'地图标注',
                    lock: true,
                    width: 700,
                    height: 500,
                    close: function(){
                        var maps = art.dialog.data('maps');
                        $("#coordinate").val(maps);
                    }
                });
            art.dialog.data('city_address', city_name);
            art.dialog.data('coordinate', $("#coordinate").val());
        });
        $("#related").click(function(){
            art.dialog.open(
                '<?php echo Yii::app()->createAbsoluteUrl("admin/public/getRelated",array('type'=>'destination','city'=>$city_id)); ?>',
                {
                    title:'周边',
                    lock: true,
                    width: 700,
                    height: 580,
                    close: function(){
                        var aid = art.dialog.data('aid');
                        var atitle = art.dialog.data('atitle');
                        if(aid && atitle){
                            var str = '';
                            str += '<li id="related_'+aid+'" style="padding:5px 5px;cursor: pointer;border-bottom: 1px solid #ccc;display: table;"><label>'+atitle+'</label><span style="margin-left: 170px;"><a href="javascript:relatedRemove('+aid+',\'related_\')">删除</a></span><input name="relation[]" value="'+aid+'" type="hidden" /></li>';
                            $("#relatedWarp").append(str);
                        }
                    }
                });
        });




    });



    $(function(){
        $("#gid").change(function() {
            loadClass($("#gid").val());
        });
        function loadClass(gid) {
            $.ajax({
                url: '<?php echo Yii::app()->createAbsoluteUrl("admin/people/loadClass"); ?>'+ 'gid/' +gid,
                type: 'POST',
                dataType: 'html',
                success: function(msg) {
                    $("#cid").html(msg);
                }
            });
        }
        $("#form").validationEngine({
            ajaxFormValidation: true,
            ajaxFormValidationURL: '<?php echo Yii::app()->createAbsoluteUrl('admin/opus/update',array('id'=>$info->id)); ?>',
            ajaxFormValidationMethod: "post",
            //validateNonVisibleFields:true,//验证隐藏字段
            onBeforeAjaxFormValidation: function (form, options) {
                luck = false;
                art.dialog.Talert('数据交互中ing', 5);
            },
            onAjaxFormComplete: function (status, form, json, options) {
                if (json['status'] == 1) {
                    art.dialog.Talert(json['message']);
                    var win = art.dialog.open.origin;
                    win.location.reload();
                } else {
                    luck = true;
                    art.dialog.Talert(json['message']);
                }
            }

        });
    });
</script>
